package com.heima.article.task;

import com.heima.article.service.IApArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author Mr_Su
 * @version v1.0
 * @date 2022/7/7 20:46
 * @desciption
 */
@Component
public class HotArticleTask {

    @Autowired
    private IApArticleService apArticleService;

//    @Scheduled(cron = "0 0 1 * * ?") // 每天凌晨一点
//    @Scheduled(cron = "0/10 * * * * ?") // 每隔10秒
    @XxlJob("computeHotArticleHandler")
    public ReturnT<String> computeHotArticle(String param){
        try{
            apArticleService.computeHotArticle();
            return ReturnT.SUCCESS;
        }catch (Exception e){
            e.printStackTrace();
            return ReturnT.FAIL;
        }
    }
}
